/*
 * Copyright 2010 Mttang.com All right reserved. This software is the
 * confidential and proprietary information of Mttang.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Mttang.com.
 */
package com.mttang.sys.integration.dao.support;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.mttang.sys.dto.MenuPrivilegeDTO;
import com.mttang.sys.integration.dao.MenuPrivilegeDAO;

/**
 * 类MenuPrivilegeDAOImpl.java的实现描述：TODO 类实现描述 
 * @author acc 2010-6-1 下午04:58:39
 */
public class MenuPrivilegeDAOImpl extends SqlMapClientDaoSupport implements     MenuPrivilegeDAO{

    private Log logger = LogFactory.getLog(getClass());
    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.MenuPrivilegeDAO#delete(com.mttang.sys.dto.MenuPrivilegeDTO)
     */
    @Override
    public void delete(Map<String ,Object>  map) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---MenuPrivilegeDAOImpl---delete");
        }
        //删除角色里面的部分具体权限
        getSqlMapClientTemplate().delete("SYS.deleteMenuRolePrv", map);
        //删除菜单的具体权限
        getSqlMapClientTemplate().delete("SYS.deleteMenuPrivilege", map);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.MenuPrivilegeDAO#findById(java.lang.Integer)
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<MenuPrivilegeDTO> findById(Integer menuId) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---MenuPrivilegeDAOImpl---findById");
        }
        return getSqlMapClientTemplate().queryForList("SYS.selectMenuPrivilegeById", menuId);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.MenuPrivilegeDAO#insert(com.mttang.sys.dto.MenuPrivilegeDTO)
     */
    @Override
    public void insert(MenuPrivilegeDTO dto) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---MenuPrivilegeDAOImpl---insert");
        }
        getSqlMapClientTemplate().insert("SYS.insertMenuPrivilege", dto);
        
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.MenuPrivilegeDAO#insertMenu(com.mttang.sys.dto.MenuPrivilegeDTO)
     */
    @Override
    public void insertMenu(MenuPrivilegeDTO dto) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---MenuPrivilegeDAOImpl---insert");
        }
        getSqlMapClientTemplate().insert("SYS.insertMenuPrv", dto);
    }

}
